package com.mzm.ui.admin;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JSplitPane;

import com.mzm.api.MzmAdminFacade;

/**
 * 
 * @author daniel
 */
public class RecommendationsManagementPanel extends JPanel {

	private CategoriesTreePanel catTreePanel;
	private ProductListPanel productListPanel;

	private RecommendationsPanel recommendationsPanel;

	private AdminContext adminContext;

	public void setMzmAdminFacade(MzmAdminFacade mzmAdminFacade) {
		this.adminContext.setMzmAdminFacade(mzmAdminFacade);
		catTreePanel.refresh();
	}

	/**
	 * Creates new form MzmAdminApp
	 */
	public RecommendationsManagementPanel() {
		catTreePanel = new CategoriesTreePanel();
		productListPanel = new ProductListPanel();
		recommendationsPanel = new RecommendationsPanel();
		adminContext = new AdminContext(productListPanel, recommendationsPanel);
		productListPanel.setAdminContext(adminContext);
		recommendationsPanel.setAdminContext(adminContext);
		catTreePanel.setAdminContext(adminContext);
		catTreePanel.addNodeSelectionListener(adminContext);
		
		JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
		JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

		JPanel left = new JPanel(new BorderLayout());
		left.add(verticalSplitPane);

		verticalSplitPane.setTopComponent(catTreePanel);
		verticalSplitPane.setBottomComponent(productListPanel);

		horizontalSplitPane.setLeftComponent(verticalSplitPane);
		horizontalSplitPane.setRightComponent(recommendationsPanel);
		horizontalSplitPane.setDividerLocation(400);
		verticalSplitPane.setDividerLocation(400);

		this.add(horizontalSplitPane, BorderLayout.CENTER);
	}

}
